// Town script for town 36: first tunnel / ? ? ? 2

begintownscript;

variables;

int x,i,j,choice;

body;

beginstate INIT_STATE;

	if (get_flag(36,7) >= 1) {
			set_terrain(39,12,137);
			set_terrain(40,12,137);
			set_terrain(41,12,137);
			}


break;

beginstate EXIT_STATE;
break;

beginstate START_STATE;
break;

beginstate 10;
	change_outdoor_location(4,2,17,19);
	move_to_new_town(31,41,14);
break;

beginstate 11;
if (get_flag(36,0) == 1)
		end();
	message_dialog("You walk further down the path, and you notice big boulders lying around. The path caved in. You'll have to find a different route.","");
	set_flag(36,0,1);
break;

beginstate 12;
if (get_flag(36,1) == 1)
		end();
	message_dialog("Its much hotter in this small cave. You think you also hear lizards hissing. It sounds like there is a lava pool near here. You'd better watch your step.","");
	set_flag(36,1,1);
break;

beginstate 13;
if (get_flag(36,2) == 1)
		end();
	message_dialog("There was a cave in in this small pathway. Its impossible to clear the path. You'll never know where the path went to.","");
	set_flag(36,2,1);
break;

beginstate 14;
if (get_flag(36,3) == 1)
		end();
	message_dialog("You walk out of the tunnel, and are amazed. Thralni made an enormous staircase here. It will probably lead you out of this tunnel. Hopefully.","There is only one small problem. There is another glowing gate here. You should try to deactivate it somehow.");
	set_flag(36,3,1);
break;

beginstate 15;
if (get_flag(36,4) == 1)
		end();
	message_dialog("As soon as you enter this cave, you start to hear hissing. It's a different hissing than you've heard from other lizards, though. It's a bit lower.","");
	set_flag(36,4,1);
break;

beginstate 16;
	move_to_new_town(38,32,29);
break;

beginstate 17;
	if (get_flag(36,5) == 0) {
			message_dialog("You come across this small patch of herbs. After studying them carefully, you recognise them as the herbs to make the explosive potion.","You quickly pick them and pocket them.");
			change_spec_item(11,1);
			set_flag(36,5,1);
			end();
			}
		message_dialog("You return to the herb patch, but there are no herbs anymore. You doubt they will grow back. To find more you'll have to find another patch of herbs.","");
break;

beginstate 18;
	if (get_flag(36,6) == 0) {
			message_dialog("You come across this small patch of herbs. After studying them carefully, you recognise them as the herbs to make the explosive potion.","You quickly pick them and pocket them.");
			change_spec_item(12,1);
			set_flag(36,6,1);
			end();
			}
		message_dialog("You return to the herb patch, but there are no herbs anymore. You doubt they will grow back. To find more you'll have to find another patch of herbs.","");
break;

beginstate 19;
if (get_flag(36,7) >= 1)
		end();
	if (has_item(484) == 1) {
			reset_dialog();
			add_dialog_str(0,"It seems as though you have made an explosive potion. This would be the perfect spot to use it. Use it?",0);
			add_dialog_choice(0,"Use the potion");
			add_dialog_choice(1,"Don't use it");
			choice = run_dialog(0);
			
				if (choice == 1) {
						message_dialog("You throw the potion to the gates, hoping for an enormous explosion. You wait. The potion hits the ground. Nothing happens. You wait a bit more.","After five minutes of waiting, you are blinded by a white light, and an intense heat fills the cave. The potion explodes, leaving almost nothing of the gates.");
						take_item(484);
						set_terrain(39,12,137);
						set_terrain(40,12,137);
						set_terrain(41,12,137);
						set_flag(36,7,1);
						}
				}
		if (get_flag(37,8) == 1)
				end();
			message_dialog("Its a pity you don't have something to blow this place up. Maybe you can find something in the laboratories of Thralni.","");
			set_flag(37,8,1);
break;

beginstate 20;
	message_dialog("The panel seems to be malfunctioning, so you won't be able to shut the gates down with this panel. You'll have to find another way.","");
break;

beginstate 21;
if (get_flag(36,9) == 1)
		end();
	message_dialog("You passed the last gates to these enormous staircase. You are already getting anxious as to see what's up there.","");
	set_flag(36,9,1);
break;